import React from 'react'
import { render } from 'react-dom'
import { ConfigProvider } from 'antd'
import zhCN from 'antd/es/locale/zh_CN'
import { BrowserRouter as Router, Route, Switch, Redirect } from 'react-router-dom'
import { constantRoutes } from './routes'
import App from './App'
import 'antd/dist/antd.less'

render(
  <Router>
    <ConfigProvider locale={zhCN}>
    <Switch>
      {
        constantRoutes.map(route => (
        <Route key={route.path} path={route.path} component={route.component} />
        ))
      }
      <Route path='/admin' component={App} />
      <Redirect to='/admin' from='/' exact />
      <Redirect to='/404' />
    </Switch>
    </ConfigProvider>
  </Router>
  ,
  document.getElementById('root')
)